package com.future.north.task;

import com.future.north.manager.DubboMonitorManager;
import com.future.north.api.model.DubboMonitor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
//@EnableScheduling   // 2.开启定时任务
public class DubboMonitorTask {
    @Autowired
    private DubboMonitorManager dubboMonitorManager;

    //3.添加定时任务
    @Scheduled(cron = "0/10 * * * * ?")
    private void run () {
        DubboMonitor dubboMonitor = new DubboMonitor();
        dubboMonitor.setApp("north");
        dubboMonitor.setUrlGroup("dubboMonitorService");
        dubboMonitor.setUrlService("com.future.north.api.service");
        Long num = dubboMonitorManager.insert(dubboMonitor);
        System.out.println(num);
    }
}
